<template>
	<view>
	  <customtop top_title="团队列表"></customtop>
		<view class="item_list container" v-if="!data_list_loading">
			<view v-if="data_list.length > 0">
				<view class="items">
					<view
						class="item"
						:class="item.level == 1 ? 'item1' : ''"
						v-for="(item, index) in data_list"
						:key="index"
					>
						<view class="captain_top" v-if="item.level == 1">{{item.nickname}}</view>
						<view class="pagetop">
							<image :src="item.avatar" class="avatar" mode="aspectFill" />
							<view class="maininfo">
								<view class="name">{{item.nickname}}</view>
								<view class="types">
									<view class="types_item">用户ID：{{item.id}}</view>
									<view class="types_item luck-text-default">{{item.level}}级</view>
									<view class="types_item">{{item.phone}}</view>
								</view>
							</view>
						</view>
						<view class="itemfoot">
							<view class="date">邀请时间：{{item.created_at}}</view>
						</view>
					</view>
				</view>
			</view>
			<u-empty
			  v-if="data_list.length == 0"
			  mode="data"
			  icon="http://cdn.uviewui.com/uview/empty/data.png"
			  text="暂无团队成员~"
			>
			</u-empty>
		</view>
	</view>
</template>

<script>
import { request } from "@/utils/http.js"
import customtop from "@/components/customtop.vue"

export default {
  components: { customtop },

  data() {
    return {
			data_list: [],
			data_list_loading: true,
    }
  },

	onShow() {
		uni.showLoading();
		this.getTeamUsers();
	},

  methods: {
		getTeamUsers: function() {
			request.post('/user/getTeamUsers').then(res => {
				uni.hideLoading();
				this.data_list_loading = false;
				this.data_list = res.data;
			})
		},

    switchTab: function(url) {
      uni.switchTab({ url: url })
    },

    jumpPage: function(url) {
      uni.navigateTo({ url: url })
    }
  }
}
</script>

<style>
@import url("team.css");
page {
  padding-bottom: 30rpx;
}
</style>
